package com.bit.cfdi.web.vm;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.zkoss.bind.annotation.Command;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.select.annotation.VariableResolver;
import org.zkoss.zk.ui.select.annotation.WireVariable;

import com.bit.cfdi.web.constants.CFDIConstants;
import com.bit.cfdi.web.session.SessionUtils;

@VariableResolver(org.zkoss.zkplus.spring.DelegatingVariableResolver.class)
public class HeaderViewModel {
	
	private Logger log = LogManager.getLogger(this.getClass().getName());
	
	//Spring Variables
	@WireVariable
	private SessionUtils sessionUtils;
	
	@Command
	public void doLogOut() {
		log.info("Performing logut");
		if(sessionUtils.logOut()) {
			Executions.getCurrent().sendRedirect(
					CFDIConstants.CFDIPages.LOGIN_URL);
		}
	}

}
